Some comments
[lhc/web/wiklou.git] / includes / SpecialRecentchangeslinked.php
1 <?php
2 /**
3 * This is to display changes made to all articles linked in an article.
4 */
5
6 /**
7 *
8 */
9 require_once( 'SpecialRecentchanges.php' );
10
11 /**
12 * Entrypoint
13 * @param string $par parent page we will look at
14 */
15 function wfSpecialRecentchangeslinked( $par = NULL ) {
16 global $wgUser, $wgOut, $wgLang, $wgTitle, $wgRequest;
17 $fname = 'wfSpecialRecentchangeslinked';
18
19 $days = $wgRequest->getInt( 'days' );
20 $target = $wgRequest->getText( 'target' );
21 $hideminor = $wgRequest->getBool( 'hideminor' ) ? 1 : 0;
22
23 $wgOut->setPagetitle( wfMsg( "recentchanges" ) );
24 $sk = $wgUser->getSkin();
25
26 if( $par ) {
27 $target = $par;
28 }
29 if ( $target == '') {
30 $wgOut->errorpage( 'notargettitle', 'notargettext' );
31 return;
32 }
33 $nt = Title::newFromURL( $target );
34 if( !$nt ) {
35 $wgOut->errorpage( 'notargettitle', 'notargettext' );
36 return;
37 }
38 $id = $nt->getArticleId();
39
40 $wgOut->setSubtitle( wfMsg( 'rclsub', $nt->getPrefixedText() ) );
41
42 if ( ! $days ) {
43 $days = $wgUser->getOption( 'rcdays' );
44 if ( ! $days ) { $days = 7; }
45 }
46 $days = (int)$days;
47 list( $limit, $offset ) = wfCheckLimits( 100, 'rclimit' );
48
49 $dbr =& wfGetDB( DB_SLAVE );
50 $cutoff = $dbr->timestamp( time() - ( $days * 86400 ) );
51
52 $hideminor = ($hideminor ? 1 : 0);
53 if ( $hideminor ) {
54 $mlink = $sk->makeKnownLink( $wgLang->specialPage( 'Recentchangeslinked' ),
55 WfMsg( 'show' ), 'target=' . htmlspecialchars( $nt->getPrefixedURL() ) .
56 "&days={$days}&limit={$limit}&hideminor=0" );
57 } else {
58 $mlink = $sk->makeKnownLink( $wgLang->specialPage( "Recentchangeslinked" ),
59 WfMsg( "hide" ), "target=" . htmlspecialchars( $nt->getPrefixedURL() ) .
60 "&days={$days}&limit={$limit}&hideminor=1" );
61 }
62 if ( $hideminor ) {
63 $cmq = 'AND cur_minor_edit=0';
64 } else { $cmq = ''; }
65
66 extract( $dbr->tableNames( 'cur', 'links' ) );
67
68 $sql = "SELECT cur_id,cur_namespace,cur_title,cur_user,cur_comment," .
69 "cur_user_text,cur_timestamp,cur_minor_edit,cur_is_new FROM $links, $cur " .
70 "WHERE cur_timestamp > '{$cutoff}' {$cmq} AND l_to=cur_id AND l_from=$id " .
71 "GROUP BY cur_id,cur_namespace,cur_title,cur_user,cur_comment,cur_user_text," .
72 "cur_timestamp,cur_minor_edit,cur_is_new,inverse_timestamp ORDER BY inverse_timestamp LIMIT {$limit}";
73 $res = $dbr->query( $sql, $fname );
74
75 $wgOut->addHTML("&lt; ".$sk->makeKnownLinkObj($nt, "", "redirect=no" )."<br />\n");
76 $note = wfMsg( "rcnote", $limit, $days );
77 $wgOut->addHTML( "<hr />\n{$note}\n<br />" );
78
79 $note = rcDayLimitlinks( $days, $limit, "Recentchangeslinked",
80 "target=" . $nt->getPrefixedURL() . "&hideminor={$hideminor}",
81 false, $mlink );
82
83 $wgOut->addHTML( $note."\n" );
84
85 $s = $sk->beginRecentChangesList();
86 $count = $dbr->numRows( $res );
87
88 $counter = 1;
89 while ( $limit ) {
90 if ( 0 == $count ) { break; }
91 $obj = $dbr->fetchObject( $res );
92 --$count;
93
94 $rc = RecentChange::newFromCurRow( $obj );
95 $rc->counter = $counter++;
96 $s .= $sk->recentChangesLine( $rc );
97 --$limit;
98 }
99 $s .= $sk->endRecentChangesList();
100
101 $dbr->freeResult( $res );
102 $wgOut->addHTML( $s );
103 }
104
105 ?>